home *** CD-ROM | disk | FTP | other *** search
- program ScreenSaver;
-
- uses
- Forms,
- SysUtils,
- Windows,
- Graphics,
- Classes,
- Dialogs,
- Controls,
- uSetup in 'uSetup.pas' {frmSetup},
- uScreenSaver in 'uScreenSaver.pas' {frmScrn},
- uGlobals in 'uGlobals.pas';
-
- {$E DAT}
-
- {$R *.RES}
-
- var
- MySem : THandle;
- Arg1,
- Arg2 : String;
- DemoWnd : HWnd;
- MyRect : TRect;
- ScrWidth,
- ScrHeight : Integer;
- SysDir : String;
- NewLen : Integer;
- MyMod : THandle;
- PwdFunc : function (a : PChar; ParentHandle : THandle; b, c : Integer) :
- Integer; stdcall;
- fs : TFileStream;
- iSize, j : integer;
- Buf : array[0..19] of Char;
- ssi : TSSImage;
- TheCanvas : TCanvas;
-
- begin
- try
- Arg1 := UpperCase(ParamStr(1));
- Arg2 := UpperCase(ParamStr(2));
-
- if (Copy(Arg1,1,2) = '/A') or (Copy(Arg1,1,2) = '-A') or
- (Copy(Arg1,1,1) = 'A') then
- SSMode := ssSetPwd;
-
- if (Copy(Arg1,1,2) = '/P') or (Copy(Arg1,1,2) = '-P') or
- (Copy(Arg1,1,1) = 'P') then
- SSMode := ssPreview;
-
- if (Copy(Arg1,1,2) = '/C') or (Copy(Arg1,1,2) = '-C') or
- (Copy(Arg1,1,1) = 'C') or (Arg1 = '') then
- SSMode := ssConfig;
-
- if SSMode = ssSetPwd then begin
- SetLength(SysDir,MAX_PATH);
- NewLen := GetSystemDirectory(PChar(SysDir),MAX_PATH);
- SetLength(SysDir,NewLen);
- if (Length(SysDir) > 0) and (SysDir[Length(SysDir)] <> '\') then
- SysDir := SysDir+'\';
- MyMod := LoadLibrary(PChar(SysDir+'MPR.DLL'));
- if MyMod <> 0 then begin
- PwdFunc := GetProcAddress(MyMod,'PwdChangePasswordA');
- if Assigned(PwdFunc) then
- PwdFunc('SCRSAVE',StrToInt(Arg2),0,0);
- FreeLibrary(MyMod);
- end;
- Halt;
- end;
-
- MySem := CreateSemaphore(nil,0,1,PChar(ExtractFileName(Application.ExeName)+'Semaphore'));
- if ((MySem <> 0) and (GetLastError = ERROR_ALREADY_EXISTS)) then begin
- CloseHandle(MySem);
- Halt;
- end;
-
- Application.Initialize;
- Application.ProcessMessages;
-
- if SSMode = ssPreview then
- begin
- DemoWnd := StrToInt(Arg2);
- while not IsWindowVisible(DemoWnd) do
- Application.ProcessMessages;
- GetWindowRect(DemoWnd,MyRect);
-
- ScrWidth := MyRect.Right-MyRect.Left+1;
- ScrHeight := MyRect.Bottom-MyRect.Top+1;
-
- TheCanvas := TCanvas.Create;
- fs := TFileStream.Create( Application.ExeName, fmOpenRead or fmShareDenyWrite );
- try
- fs.Position := fs.Size-40;
- j := fs.Read(Buf,20);
- if j <> 20 then exit;
- iSize := StrToIntDef(Trim(buf),0);
-
- fs.Position := fs.Size-iSize-40;
-
- TheCanvas.Handle := GetDC(DemoWnd);
- ssi := TSSImage(fs.ReadComponent(nil));
- try
- TheCanvas.StretchDraw(Rect(0,0,ScrWidth,ScrHeight),ssi.Picture.Graphic);
- finally
- ssi.Free;
- end;
- while IsWindowVisible(DemoWnd) do
- begin
- Application.ProcessMessages;
- if not IsWindowVisible(DemoWnd) then break;
- end;
- finally
- fs.free;
- TheCanvas.Free;
- end;
-
- CloseHandle(MySem);
- Halt;
- end;
-
- if SSMode = ssConfig then begin
- Application.CreateForm(TfrmSetup, frmSetup);
- end else
- Application.CreateForm(TfrmScrn,frmScrn);
-
- Application.Run;
- Application.ProcessMessages;
-
- CloseHandle(MySem);
- except
- end;
- end.
-
-